﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Input;
using VMDS.Business.Entities;
using VMDS.GUIClient.Helper;
using VMDS.GUIClient.Model;

namespace VMDS.GUIClient.ViewModels.Management.VMs
{
    class AddScrDialogViewModel:BaseViewModel
    {
        private string _path;
        public string Path
        {
            get { return _path; }
            set { _path = value;
                ShowMessageBox(value);
                OnPropertyChanged(() => Path);
                OnPropertyChanged(() => Upload);
            }
        }

        private int _progress;
        public int Progress
        {
            get { return _progress; }
            set { _progress = value;
                OnPropertyChanged(() => Progress);
            }
        }

        private bool _vis;
        public bool Visible
        {
            get { return _vis; }
            set { _vis = value;
                OnPropertyChanged(() => Visible);
            }
        }

        public ICommand Upload { get { return comm(); } }
        BaseCommand comm()
        {
            return new BaseCommand(upload, () => { return File.Exists(Path); });
        }
        private void upload()
        {
            ScreenShot scr = new ScreenShot();
            FileInfo fi = new FileInfo(Path);
            string newpath = ManagerDataStore.Instance.ShareUNC+"\\"+fi.Name;
            File.Copy(Path, newpath);
            scr.FileName = newpath;
            scr.VMId = ManagerDataStore.Instance.CurrentVM.Id;
            //MsLocator.Client.AddScreenShot(scr);
            ManagerDataStore.Instance.LoadData();
            Visible = false;
        }
        public AddScrDialogViewModel()
        {
            Visible = true;   
        }

    }
}
